home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_d / dss9115.zip / DSS.TXT
Text File  |  1991-10-18  |  35KB  |  862 lines

  1.      ( Appeared in the Federal Register dated August 30, 1991 ) 
  2.  
  3.                      DEPARTMENT OF COMMERCE
  4.          National Institute of Standards and Technology
  5.  
  6.  
  7.        A PROPOSED FEDERAL INFORMATION PROCESSING STANDARD 
  8.                               FOR 
  9.                 DIGITAL SIGNATURE STANDARD (DSS)
  10.  
  11.  
  12. AGENCY:   National Institute of Standards and Technology (NIST),
  13. Commerce.
  14.  
  15. ACTION:   Notice; Request for Comments.
  16.  
  17. SUMMARY:  A Federal Information Processing Standard (FIPS) for
  18. Digital Signature Standard (DSS) is being proposed.  This
  19. proposed standard specifies a public-key based digital signature
  20. algorithm (DSA) appropriate for Federal digital signature
  21. applications.  The proposed DSS uses a public key to verify to a
  22. recipient the integrity of data and the identity of the sender of
  23. the data.  The DSS can also be used by a third party to ascertain
  24. the authenticity of a signature and the data associated with it.
  25.  
  26. This proposed standard adopts a public-key signature system that
  27. uses a pair of transformations to generate and verify a digital
  28. value called a signature.  The government has applied to the U.S.
  29. Patent Office for a patent on this technique.  The government
  30. will also seek foreign patents as appropriate.  NIST intends to
  31. make this DSS technique available world-wide on a royalty-free
  32. basis in the public interest.  We believe this technique is
  33. patentable and that no other patents would apply to the DSS, but
  34. we cannot give firm assurances to such effect in advance of
  35. issuance of the patent.
  36.  
  37. The purpose of this notice is to solicit views from the public,
  38. manufacturers, and Federal, state, and local government users so
  39. that their needs can be considered prior to submission of this
  40. proposed standard to the Secretary of Commerce for review and
  41. approval.
  42.  
  43. The proposed standard contains two sections:  (1) an announcement
  44. section, which provides information concerning the applicability,
  45. implementation, and maintenance of the standard; and (2) a
  46. specifications section which deals with the technical aspects of
  47. the standard.  Only the announcement section of the standard is
  48. provided in this notice.  Interested parties may obtain copies of
  49. the specifications section from the Standards Processing
  50. Coordinator (ADP), National Institute of Standards and
  51. Technology, Technology Building, Room B-64, Gaithersburg, MD 
  52. 20899, telephone (301) 975-2816.  
  53.  
  54. DATE:  Comments on this proposed standard must be received on or
  55. before (please insert date which is ninety (90) days from the
  56. date of publication of this notice in the Federal Register).
  57.  
  58.  
  59. ADDRESS:  Written comments concerning the proposed standard
  60. should be sent to: Director, Computer Systems Laboratory, ATTN:
  61. Proposed FIPS for DSS, Technology Building, Room B-154, National
  62. Institute of Standards and Technology, Gaithersburg, MD  20899.
  63.  
  64. Written comments received in response to this notice will be made
  65. part of the public record and will be made available for
  66. inspection and copying in the Central Reference and Records
  67. Inspection Facility, Room 6020, Herbert C. Hoover Building, 14th
  68. Street between Pennsylvania and Constitution Avenues, NW,
  69. Washington, DC  20230.
  70.  
  71. FOR FURTHER INFORMATION CONTACT:  Mr. Miles Smid, National
  72. Institute of Standards and Technology, Gaithersburg, MD  20899,
  73. telephone (301) 975-2938.
  74.  
  75. SUPPLEMENTARY INFORMATION:  This proposed FIPS is the result of
  76. evaluating a number of alternative digital signature techniques. 
  77. In making the selection, the NIST has followed the mandate
  78. contained in section 2 of the Computer Security Act of 1987 that
  79. NIST develop standards and guidelines to "... assure the cost-
  80. effective security and privacy of sensitive information in
  81. Federal systems".  In meeting this statutory responsibility, NIST
  82. has placed primary emphasis on selecting the technology that best
  83. assures the appropriate security of Federal information and,
  84. among technologies offering comparable protection, on selecting
  85. the option with the most desirable operating and use
  86. characteristics.  
  87.  
  88. Among the factors that were considered during this process were
  89. the level of security provided, the ease of implementation in
  90. both hardware and software, the ease of export from the U.S., the
  91. applicability of patents, impact on national security and law
  92. enforcement and the level of efficiency in both the signing and
  93. verification functions.  A number of techniques were deemed to
  94. provide appropriate protection for Federal systems.  The
  95. technique selected has the following desirable characteristics:
  96.  
  97.      --   NIST expects it to be available for public use on a
  98.           royalty-free basis.  Broader use of this technique
  99.           resulting from public availability should be an
  100.           economic benefit to the government and the public.
  101.  
  102.      --   The technique selected provides for efficient
  103.           implementation of the signature operations in smart
  104.           card applications.  In these applications the signing
  105.           operations are performed in the computationally modest
  106.           environment of the smart card while the verification
  107.           process is implemented in a more computationally rich
  108.           environment such as a personal computer, a hardware
  109.           cryptographic module, or a mainframe computer.
  110.  
  111. NIST has received agreement from Department of Defense
  112. authorities that this digital signature technique may be used to
  113. sign unclassified data processed by "Warner Amendment" systems
  114. (10 U.S.C. 2315 and 44 U.S.C. 3502(2)) as well as classified data
  115. in selected applications.
  116.  
  117. A hashing function has not been specified by NIST at this time
  118. for use with the DSS.  NIST has been reviewing various candidate
  119. hashing functions; however, we are not satisfied with any of the
  120. functions we have studied thus far.  NIST does intend to publish
  121. a hashing function that is complementary to the DSS.
  122.  
  123.  
  124. (NOTE:  Original signed by Dr. John Lyons, NIST Director)
  125.  
  126.  
  127. ***********************************************************************
  128.  
  129.  ( The following is the Proposed Digital Signature Standard)
  130.  
  131.                               A PROPOSED 
  132.  
  133.                    DIGITAL SIGNATURE STANDARD (DSS) 
  134.  
  135.                                Foreword 
  136.  
  137.  
  138.    The Federal Information Processing Standards Publication
  139. Series of the National Institute of Standards and Technology (NIST) is
  140. the official series of publications relating to standards and 
  141. guidelines adopted and promulgated under the provisions of
  142. Section 111(d) of the Federal Property and Administrative
  143. Services Act of 1949 as amended by the Computer Security Act of
  144. 1987, Public Law 100-235.  These mandates have given the
  145. Secretary of Commerce and NIST important responsibilities for
  146. improving the utilization and management of computer and related
  147. telecommunications systems in the Federal Government.  The NIST,
  148. through the Computer Systems Laboratory, provides leadership,
  149. technical guidance, and coordination of Government efforts in the
  150. development of standards and guidelines in these areas.  
  151.  
  152.    Comments concerning Federal Information Processing Standards 
  153. Publications are welcomed and should be addressed to the
  154. Director, Computer Systems Laboratory, National Institute of Standards and
  155. Technology, Gaithersburg, MD 20899. 
  156.  
  157.  
  158.                            James H. Burrows, Director 
  159.                            Computer Systems Laboratory  
  160.  
  161.  
  162.                                Abstract 
  163.  
  164.    This standard specifies a Digital Signature Algorithm (DSA) 
  165. which can be used to generate a digital signature.  Digital 
  166. signatures are used to detect unauthorized modifications to data
  167. and to authenticate the identity of the user who generates the 
  168. signature.  In addition, the recipient of signed data can use a 
  169. digital signature in proving to a third party that the signature
  170. was in fact generated by the signer of the data.  This is known
  171. as nonrepudiation since the signer of data cannot, at a later
  172. time, repudiate the signature. 
  173.  
  174. Key words: ADP security, computer security, digital signatures, 
  175. public-key cryptography, Federal Information Processing Standard.
  176.  
  177.  
  178.  
  179.                           Federal Information 
  180.                   Processing Standards Publication XX 
  181.  
  182.  
  183.                              ANNOUNCING A 
  184.  
  185.                       DIGITAL SIGNATURE STANDARD 
  186.  
  187.  
  188. Federal Information Processing Standards Publications (FIPS PUBS)
  189. are issued by the National Institute of Standards and Technology
  190. (NIST) after approval by the Secretary of Commerce pursuant to 
  191. Section 111(d) of the Federal Property and Administrative
  192. Services Act of 1949 as amended by the Computer Security Act of 1987,
  193. Public Law 100-235. 
  194.  
  195. Name of Standard: Digital Signature Standard. 
  196.  
  197. Category of Standard: ADP Operations, Computer Security. 
  198.  
  199. Explanation: This Standard specifies a Digital Signature Algorithm
  200. (DSA) appropriate for applications requiring a digital rather
  201. than written signature.  The DSA digital signature is a pair of
  202. large numbers represented in a computer as strings of binary
  203. digits.  The digital signature is computed using a set of rules
  204. (i.e., the DSA) and a set of parameters such that it can be used to verify
  205. the identity of the originator and integrity of the data.  The DSA 
  206. includes signature generation and verification.  Generation makes
  207. use of a private key to generate a digital signature.  Verification
  208. of the signature makes use of a public key which corresponds to,
  209. but is not the same as, the private key used to generate the 
  210. signature.  Each user possesses a private and public key pair.  
  211. Public keys are assumed to be known to all members of a group of
  212. users or to the public in general.  Private keys must be known
  213. only by their creators.  Anyone can verify the signature of a user by
  214. employing that user's public key.  Signature generation can be 
  215. performed only by the possessor of the user's private key. 
  216. A hash function is used in the signature generation process to 
  217. obtain a condensed version of data, called a message digest. The
  218. message digest is then signed.  The digital signature is sent to
  219. the intended recipient along with the signed data (often called
  220. the message).  The recipient of the message and signature verifies
  221. the signature by using the sender's public key.  The same hash
  222. function must also be used in the verification process.  The hash function
  223. will be specified in a separate standard.  Similar procedures may
  224. be used to generate and verify signatures for stored as well as 
  225. transmitted data. 
  226.  
  227. Approving Authority: Secretary of Commerce. 
  228.  
  229. Maintenance  Agency: Computer Systems Laboratory, National 
  230. Institute of Standards and Technology. 
  231.  
  232. Applicability: This standard is applicable to all Federal 
  233. departments and agencies for the protection of unclassified 
  234. information that is not subject to section 2315 of Title 10,
  235. United States Code, or section 3502(2) of Title 44, United States Code. 
  236. This standard shall be used in designing and implementing 
  237. Public-key based signature systems which Federal departments and
  238. agencies operate or which are operated for them under contract. 
  239. Private and commercial organizations are encouraged to adopt and
  240. use this standard.  
  241.  
  242. Applications: The DSA authenticates the integrity of the signed 
  243. data and the identity of the signer.  The DSA may also be used in
  244. proving to a third party that data was actually signed by the 
  245. generator of the signature.  The DSA is intended for use in 
  246. electronic mail, electronic funds transfer, electronic data 
  247. interchange, software distribution, data storage, and other 
  248. applications which require data integrity assurance and data
  249. origin authentication. 
  250.  
  251. Implementations: The DSA may be implemented in software, firmware
  252. or hardware.  Only implementations of the DSA that are validated
  253. by NIST will be considered as complying with this standard.  
  254. Information about the requirements for validating implementations
  255. of this standard can be obtained from the National Institute of 
  256. Standards and Technology, Computer Systems Laboratory, Attn: DSS
  257. Validation, Gaithersburg, MD 20899. 
  258.  
  259. Export Control: Implementations of this standard are subject to 
  260. Federal Government export controls as specified in Title 15, Code
  261. of Federal Regulations, Parts 768 through 799.  Exporters are 
  262. advised to contact the Department of Commerce, Bureau of Export 
  263. Administration for more information. 
  264.  
  265. Patents: Implementations of the DSA in this standard may be
  266. covered by U.S. and foreign patents. 
  267.  
  268. Implementation Schedule: This standard becomes effective six
  269. months after the publication date of this FIPS PUB. 
  270.  
  271. Specifications: Federal Information Processing Standard (FIPS XX)
  272. Digital Signature Standard (affixed). 
  273.  
  274. Cross Index: 
  275.  
  276.    a. FIPS PUB 46-1, Data Encryption Standard. 
  277.  
  278.    b. FIPS PUB 73, Guidelines for Security of Computer           
  279.       Applications. 
  280.  
  281.    c. FIPS PUB 140-1, Security Requirements for Cryptographic    
  282.       Modules. 
  283.  
  284. Qualifications: The security of a digital signature system is 
  285. dependent on maintaining the secrecy of users' private keys. 
  286. Users must therefore guard against the unauthorized acquisition of
  287. their private keys.  While it is the intent of this standard to specify
  288. general security requirements for generating digital signatures,
  289. conformance to this standard does not assure that a particular 
  290. implementation is secure.  The responsible authority in each agency
  291. or department shall assure that an overall implementation provides
  292. an acceptable level of security.  This standard will be reviewed
  293. every five years in order to assess its adequacy. 
  294.  
  295. Waiver Procedure: Under certain exceptional circumstances, the 
  296. heads of Federal departments and agencies may approve waivers to
  297. Federal Information Processing Standards (FIPS).  The head of
  298. such agency may redelegate such authority only to a senior official 
  299. designated pursuant to section 3506(b) of Title 44, United States
  300. Code.  Waiver shall be granted only when: 
  301.  
  302.    a. Compliance with a standard would adversely affect the      
  303.       accomplishment of the mission of an operator of a Federal  
  304.       computer system; or 
  305.  
  306.    b. Compliance with a standard would cause a major adverse 
  307.       financial impact on the operator which is not offset by 
  308.       Government-wide savings. 
  309.  
  310. Agency heads may act upon a written waiver request containing the
  311. information detailed above.  Agency heads may also act without a
  312. written waiver request when they determine that conditions for 
  313. meeting the standard cannot be met.  Agency heads may approve 
  314. waivers only by a written decision which explains the basis on 
  315. which the agency head made with required finding(s).  A copy of 
  316. each decision, with procurement sensitive or classified portions
  317. clearly identified, shall be sent to: National Institute of 
  318. Standards and Technology; ATTN: FIPS Waiver Decisions, Technology
  319. Building, Room B-154, Gaithersburg, MD 20899. 
  320.  
  321. In addition, notice of each waiver granted and each delegation of
  322. authority to approve waivers shall be sent promptly to the 
  323. Committee on Government Operations of the House of
  324. Representatives and the Committee on Government Affairs of the Senate and
  325. shall be published promptly in the Federal Register. 
  326. When the determination on a waiver applies to the procurement of
  327. equipment and/or services, a notice of the waiver determination 
  328. must be published in the Commerce Business Daily as a part of the
  329. notice of solicitation for offers of an acquisition or, if the 
  330. waiver determination is made after that notice is published, by 
  331. amendment to such notice. 
  332.  
  333. A copy of the waiver, any supporting documents, the document 
  334. approving the waiver and any accompanying documents, with such 
  335. deletions as the agency is authorized and decides to make under 5
  336. United States Code Section 552(b), shall be part of the
  337. procurement documentation and retained by the agency. 
  338.  
  339. Where to Obtain Copies of the Standard: Copies of this
  340. publication are for sale by the National Technical Information Service, U.S.
  341. Department of Commerce, Springfield, VA 22161.  When ordering, 
  342. refer to Federal Information Processing Standards Publication XX
  343. (FIPS PUB XX), and identify the title.  When microfiche is
  344. desired, this should be specified.  Prices are published by NTIS in
  345. current catalogs and other issuances.  Payment may be made by check,
  346. money order, deposit account or charged to a credit card accepted by 
  347. NTIS. 
  348.  
  349.  
  350.                           Federal Information 
  351.                   Processing Standards Publication XX 
  352.  
  353.  
  354.                          Specifications for a 
  355.  
  356.  
  357.  
  358.                      DIGITAL SIGNATURE STANDARD (DSS) 
  359.  
  360.  
  361.  
  362.                             1. INTRODUCTION 
  363.  
  364.    This publication prescribes the Digital Signature Algorithm 
  365. (DSA) for digital signature generation and verification.  
  366. Additional information is provided in Appendices 1 through 5.  
  367.  
  368.  
  369.                               2. GENERAL 
  370.  
  371.    When a message is transmitted from one party to another, the 
  372. recipient may desire to know that the message has not been
  373. altered in transit.  Furthermore, the recipient may wish to be certain of
  374. the origin of the message.  Both of these services can be
  375. provided by the DSA.  A digital signature is an electronic analogue of a 
  376. written signature, in that the digital signature can be used in 
  377. proving to a third party that the message was, in fact, signed by
  378. the originator.  Unlike their written counterparts, digital 
  379. signatures also verify the integrity of messages.  It is also 
  380. desirable to be able to generate digital signatures for stored
  381. data and programs so that the integrity of the data and programs may
  382. be verified at any later time. 
  383.  
  384.    This publication prescribes the DSA for digital signature 
  385. generation and verification.  In addition, the criteria for the 
  386. public and private keys required by the algorithm are provided. 
  387.  
  388.  
  389.                       3. USE OF THE DSA ALGORITHM 
  390.  
  391.    A private and public key pair is used to generate and verify a
  392. digital signature.  These keys are employed in conjunction with a
  393. hash function H, which is not specified in this standard.  The 
  394. holder of a private key can generate a signature for data,
  395. referred to as the message, m.  A holder of the corresponding public key
  396. can verify the signature.  Both signature generation and verification
  397. use H.  An adversary, who does not know the private key of a
  398. user, cannot generate that user's signature for a message.  In other 
  399. words, signatures cannot be forged:  an adversary cannot generate
  400. a correct signature for another person for any message.  However,
  401. by using the appropriate public key, anyone can check that a
  402. given signature is valid. 
  403.  
  404.    A means of associating public and private key pairs to the 
  405. corresponding users is required.  That is, there must be a
  406. binding of a user's identity and the user's public key. This binding may
  407. be  certified by a mutually trusted party.  For example, a certifying
  408. authority could sign credentials containing a user's public key
  409. and identity to form a certificate.  Systems for certifying
  410. credentials and distributing certificates are beyond the scope of this 
  411. standard. NIST intends to publish separate document(s) on 
  412. certifying credentials and distributing certificates. 
  413.  
  414.  
  415.                         4. DSA PARAMETERS 
  416.  
  417.    Let 
  418.  
  419. A. p = a prime modulus where 2^511 < p < 2^512. 
  420.  
  421. B. q = a prime divisor of p - 1 where 2^159 < q < 2^160. 
  422.  
  423. C. g = h^((p-1)/q) mod p, where h is any integer with 0 < h < p
  424. such that  h^((p-1)/q) mod p > 1. 
  425.  
  426. D. x = an integer with 0 < x < q. 
  427.  
  428. E. y = g^x mod p. 
  429.  
  430. F. m = the message to be signed and transmitted. 
  431.  
  432. G. k = a random integer with 0 < k < q. 
  433.  
  434. H. H = a one-way hash function. 
  435.  
  436.    The integers p, q, and g can be public and can be common to a
  437. group of users.  A user's private and public keys are x and y, 
  438. respectively. x and k must be secret. k must be changed for each
  439. signature. H is not specified in this standard. However, H must
  440. be chosen so that it is computationally infeasible to create a
  441. message which results in a given hash value and it must also be 
  442. computationally infeasible to find any two different messages
  443. which result in the same hash value. 
  444.  
  445.                         5. SIGNATURE GENERATION 
  446.  
  447.    To send a signed message m the user chooses a random k and 
  448. computes 
  449.  
  450.       r = (g^k mod p) mod q 
  451.  
  452.       s = (k^-1 (H(m) + xr)) mod q. 
  453.  
  454. where k^-1 is the multiplicative inverse of k, mod q; i.e., (k^-1 k) 
  455. mod q = 1 and 0 < k^-1 < q. 
  456.  
  457.    The values r and s constitute the signature of the message. 
  458. These are transmitted along with the message m to the recipient.
  459.  
  460.  
  461.  
  462.                        6. SIGNATURE VERIFICATION 
  463.  
  464.    Prior to verifying the signature in a signed message, p, q and
  465. g plus the sender's public key and identity are made available to
  466. the recipient in an authenticated manner. 
  467.  
  468.    Let m', r', and s' be the received versions of m, r, and s, 
  469. respectively, and let y be the public key of the sender.  To
  470. verify the signature, the recipient first checks to see that 0 < r' < q
  471. and 0 < s' < q; if either condition is violated the signature is
  472. rejected. If these two conditions are satisfied, the recipient 
  473. computes:  
  474.  
  475.       w  = (s')^-1 mod q 
  476.  
  477.       u1 = ((H(m'))w) mod q 
  478.  
  479.       u2 = ((r')w) mod q 
  480.    
  481.       v  = (((g)^(u1) (y)^(u2)) mod p) mod q. 
  482.  
  483.    If v = r', then the signature is verified and the receiver can
  484. have high confidence that the received message was sent by the 
  485. party holding the secret key x corresponding to y. For a proof that
  486. v = r' when m' = m, r' = r, and s' = s, see Appendix 1. 
  487.  
  488.    If v does not equal r', then the message may have been modified,
  489. the message may have been incorrectly signed by the sender, or
  490. the message may have been signed by an impostor.  The message should
  491. be considered invalid. 
  492.  
  493.                          Appendix 1 
  494.                      A Proof that v = r' 
  495.  
  496.    This appendix is for informational purposes only and is not 
  497. required to meet the standard. 
  498.  
  499.    The purpose of this appendix is to provide a rigorous proof that
  500. in the signature verification (Section 6 of the DSS) we have v =
  501. r'  when m' = m, r' = r, and s' = s. The proof is given by the Theorem
  502. below; it is preceded by four lemmas. 
  503.  
  504.    LEMMA 1. For any nonnegative integer t, if g = h^((p-1)/q) mod
  505. p, then 
  506.  
  507.      g^t mod p = g^(t mod q) mod p. 
  508.  
  509.    Proof: By the Euler/Fermat theorem, since h is relatively prime
  510. to p, we have h^(p-1) mod p = 1. Hence for any nonnegative
  511. integer n, 
  512.  
  513.   g^(nq) mod p = (h^((p-1)/q) mod p)^(nq) mod p 
  514.  
  515.                = h^(((p-1)/q)nq) mod p 
  516.  
  517.                = h^((p-1)n) mod p  
  518.  
  519.                = ((h^(p-1) mod p)^n) mod p 
  520.  
  521.                = 1^n mod p 
  522.  
  523.                = 1. 
  524.  
  525.    Thus, for any nonnegative integers n and z we have 
  526.  
  527.    g^(nq+z) mod p = (g^(nq) g^z) mod p 
  528.                    
  529.                   = ((g^(nq) mod p) (g^z mod p)) mod p 
  530.                    
  531.                   = g^z mod p. 
  532.  
  533.    Any nonnegative integer t can be represented uniquely as t = nq
  534. + z where n and z are nonnegative integers and 0 s z < q. Then 
  535.  
  536.       g^t mod p = g^z mod p. 
  537.  
  538.    Also, z = t mod q. The result follows. QED. 
  539.  
  540.    LEMMA 2. For any nonnegative integers a and b, 
  541.  
  542.       g^(a mod q + b mod q) mod p = g^((a + b) mod q) mod p. 
  543.  
  544.    Proof: By Lemma 1 we have 
  545.  
  546.   g^(a mod q + b mod q) mod p = g^((a mod q + b mod q) mod q) mod p 
  547.  
  548.                               =  g^((a + b) mod q) mod p. 
  549.  
  550.    QED. 
  551.  
  552.    LEMMA 3.  
  553.  
  554.       y^((rw) mod q) mod p = g^((xrw) mod q) mod p. 
  555.  
  556.    Proof: Since y = g^x mod p, using Lemma 1 we have 
  557.  
  558.    y^((rw) mod q) mod p = (g^x mod p)^((rw) mod q) mod p 
  559.  
  560.                         = g^(x((rw) mod q)) mod p 
  561.  
  562.                         = g^((x((rw) mod q)) mod q) mod p  (by Lemma 1) 
  563.  
  564.                         = g^((xrw) mod q) mod p. 
  565.  
  566.    QED. 
  567.  
  568.    LEMMA 4. 
  569.  
  570.       ((H(m) + xr)w) mod q = k. 
  571.  
  572.    Proof: We have 
  573.  
  574.       s = (k^-1 (H(m) + xr)) mod q. 
  575.  
  576.    Since (k k^-1) mod q = 1, 
  577.  
  578.       (ks) mod q = (k((k^-1 (H(m) + xr)) mod q)) mod q 
  579.  
  580.                  = ((k(k^-1 (H(m) + xr)))) mod q 
  581.  
  582.                  = (((k k^-1) mod q) ((H(m) + xr) mod q)) mod q 
  583.  
  584.                  = (H(m) + xr) mod q. 
  585.  
  586.    Since w = s^-1 mod q we have (ws) mod q = 1, and thus 
  587.  
  588.       ((H(m) + xr)w) mod q = (((H(m) + xr) mod q) (w mod q)) mod q
  589.  
  590.                            = (((ks) mod q) (w mod q)) mod q 
  591.                             
  592.                            = (kws) mod q 
  593.       
  594.                            = ((k mod q) ((ws) mod q)) mod q 
  595.  
  596.                            =  k mod q. 
  597.  
  598.    Since 0 < k < q we have k mod q = k. QED. 
  599.  
  600.    THEOREM. If m' = m, r' = r, and s' = s, then v = r'. 
  601.  
  602.    Proof: Using Lemmas 2, 3 and 4 we find 
  603.  
  604.       v = ((g^(u1) y^(u2)) mod p) mod q 
  605.  
  606.         = ((g^((H(m)w) mod q) y^((rw) mod q)) mod p) mod q 
  607.  
  608.         = ((g^((H(m)w) mod q) g^((xrw) mod q)) mod p) mod q (by Lemma 3) 
  609.       
  610.         = ((g^((H(m)w) mod q + (xrw) mod q)) mod p) mod q 
  611.  
  612.         = ((g^(((H(m)w) mod q + (xrw) mod q) mod q)) mod p) mod q
  613.  
  614.         = ((g^((H(m)w + xrw) mod q)) mod p) mod q     (by Lemma 2)
  615.  
  616.         = ((g^(((H(m) + xr)w) mod q)) mod p) mod q 
  617.  
  618.         = (g^k mod p) mod q     (by Lemma 4) 
  619.  
  620.         = r  
  621.      
  622.         = r'. 
  623.  
  624.    QED. 
  625.  
  626.                            Appendix 2 
  627.               Generation of Parameters for the DSA 
  628.  
  629.    This appendix is for informational purposes only and is not 
  630. required to meet the standard. 
  631.  
  632.    This appendix includes suggestions for generating the parameters
  633. and performing the functions needed to implement the DSA.  These
  634. algorithms require a random number generator (see Appendix 3),
  635. and an efficient modular exponentiation algorithm (see Appendix 4). 
  636. In  order to generate the primes p and q, a primality test is required. 
  637. There are several fast probabilistic algorithms available.  The 
  638. following algorithm is a simplified version of a procedure due to
  639. M.O. Rabin, based in part on ideas of Gary L. Miller.  [See
  640. Knuth, The Art of Computer Programming, Vol. 2, Addison-Wesley, 1981, 
  641. Algorithm P,page 379.]  If this algorithm is iterated n times, it
  642. will produce a false prime with probability no greater than 1/4^n. 
  643.  
  644. Therefore, n=50 should give an acceptable probability of error. 
  645. To  test whether an integer is prime: 
  646.  
  647.    1. Set i = 1 and n = 50. 
  648.    2. Set w = the integer to be tested, w = 1 + 2^a m, 
  649.       where m is odd and 2^a is the largest power of 2 dividing w-1. 
  650.    3. Generate a random integer b in the range 1<b<w. 
  651.    4. Set j = 0 and z = b^m mod w. 
  652.    5. If j = 0 and z = 1, or if z = w-1, go to step 9. 
  653.    6. If j> 0 and z = 1, go to step 8. 
  654.    7. j = j + 1. If j < a, set z = z^2 mod w and go to step 6. 
  655.    8. w is not prime.  Stop. 
  656.    9. If i< n, set i = i + 1 and go to step 3.  Otherwise, w 
  657.       is probably prime. 
  658.  
  659. To generate a prime q where 2^159 < q < 2^160: 
  660.  
  661.    1. Set n = a random number between 2^158 and 2^159 - 1, inclusive. 
  662.    2. Set t = 2n + 1. 
  663.    3. If t < 2^160, test whether t is prime.  Otherwise, go to step
  664.       1.   
  665.    4. If t is prime, set q = t.  Otherwise, set t = t + 2 and go to  
  666.       step 3.  
  667.  
  668. To generate a prime p where 2^511 < p < 2^512 and q divides p - 1:
  669.  
  670.  
  671.    1. Generate q as specified above. 
  672.    2. Generate a random integer n, where n is between (2^511-1)/(2q) 
  673.       and (2^512-1)/(2q). 
  674.    3. Set t = 2nq + 1. 
  675.    4. Test whether t is prime. 
  676.    5. If t is prime, set p = t.  Otherwise, go to step 2. 
  677.  
  678. To generate an element g of order q mod p: 
  679.  
  680.    1.  Generate p and q as specified above. 
  681.    2.  Set h = a random number, where 1 < h < p-1. 
  682.    3.  Set t = h^((p-1)/q) mod p. 
  683.    4.  If t = 1 then go to step 2.  Otherwise, set g = t. 
  684.  
  685. To generate integers x and k: 
  686.  
  687.    Set x and k equal to random integers between 0 and q. 
  688.  
  689. To generate y: 
  690.  
  691.    Set y = g^x mod p. 
  692.  
  693. To compute the signature (r,s) of a message m: 
  694.  
  695.    1.  Set t = g^k mod p. 
  696.    2.  Set r = t mod q. 
  697.    3.  Set h = H(m) where H is a hash function. 
  698.    4.  Calculate k^-1 mod q as described below. 
  699.    5.  Set s = ((k^-1) (h + xr)) mod q. 
  700.  
  701. To verify the signature (r,s) of a message m: 
  702.  
  703.    1.  m, r, and s are received as m', r', and s', respectively.
  704.    2.  If r' <= 0 or r' >= q then reject the signature as invalid.
  705.    3.  If s' <= 0 or s' >= q then reject the signature as invalid.
  706.    4.  Set h = H(m'). 
  707.    5.  Calculate w = s'^-1 mod q as described below. 
  708.    6.  Set u1 = (hw) mod q. 
  709.    7.  Set u2 = (r'w) mod q. 
  710.    8.  Set a = g^(u1) mod p. 
  711.    9.  Set b = y^(u2) mod p. 
  712.   10.  Set t = (ab) mod p. 
  713.   11.  Set v = t mod q. 
  714.   12.  If v = r', signature is verified.  Otherwise, reject      
  715.        signature as invalid. 
  716.   
  717. To compute the multiplicative inverse n^-1 mod q for n with 0 < n
  718. < q: 
  719.  
  720.    1. Set i = q, h = n, v = 0 and d = 1. 
  721.    2. While h > 0 repeat steps 3 thru 5. 
  722.    3. t = i DIV h where DIV is defined as integer division. 
  723.    4. Set x = h, h = i - tx and i = x. 
  724.    5. Set x = d, d = v - tx and v = x. 
  725.    6. n^-1 = v mod q. 
  726.  
  727.          
  728.                            Appendix 3 
  729.               Random Number Generation for the DSA 
  730.  
  731.    This appendix is for informational purposes only and is not 
  732. required to meet the standard. 
  733.  
  734.    Any implementation of the DSA requires the ability to generate
  735. random numbers.  Random numbers are used to derive a user's private
  736. key and a user's per message random secret number.  These random
  737. numbers are selected to be between 0 and the 160-bit prime q (as
  738. specified in the standard).  The numbers can be generated by either
  739. a true noise hardware randomizer or via a pseudorandom function. 
  740. Such a function would employ a user generated and secret "seed"
  741. key to initialize the number generator.  The generator then would 
  742. produce a stream of bits or numbers which could be converted into
  743. the integers mod q discussed above.  One such pseudorandom number
  744. generator is the key generation methodology found in Appendix C of
  745. ANSI X9.17, "Financial Institution Key Management (Wholesale)". 
  746.  
  747.        
  748.                            Appendix 4 
  749.                  Modular Arithmetic for the DSA 
  750.  
  751.    This appendix is for informational purposes only and is not 
  752. required to meet the standard. 
  753.  
  754.    One key to efficient implementation of the Digital Signature 
  755. Standard is the development of a modular arithmetic package suited
  756. to the processor one intends to use.  For the purposes of this 
  757. discussion, we will consider two types of processors: hardware and
  758. software and suggest some techniques which may allow for
  759. efficient implementation of the DSA in those systems. 
  760.  
  761.    With respect to hardware implementations an excellent reference
  762. is "VLSI Implementation of Public Key Encryption Algorithms" by 
  763. Orton, Roy, Scott, Peppard and Tavares from the Proceedings of 
  764. CRYPTO-86.  That paper and the references found at its end will 
  765. provide a good basis for anyone looking into hardware 
  766. implementations of the DSA.  It is also worth noting that several
  767. commercial firms have custom processors to do modular arithmetic
  768. on the market. 
  769.  
  770.    With respect to software implementations, there are many 
  771. different ways to proceed and a rich literature containing 
  772. different techniques for different computing environments.  For 
  773. instance, the algorithms one chooses for 32-bit processors may be
  774. substantially different than those which would be appropriate for
  775. 8-bit processors.  Likewise, one can make trade offs on
  776. computation versus memory in various algorithms.  Good starting places for 
  777. modular arithmetic algorithms in software are found in "A 
  778. Cryptographic Library for the Motorola DSP56000" by Dusse and 
  779. Kaliski from the Proceedings of EUROCRYPT-90 and "Implementing the
  780. Rivest Shamir and Adleman Public Key Encryption Algorithm on a 
  781. Standard Digital Signal Processor" by Barrett from the Proceedings
  782. of CRYPTO-86.  These papers contain pseudo-code for some of the
  783. more popular techniques used in modular arithmetic. 
  784.  
  785.                            Appendix 5 
  786.                        Example of the DSA 
  787.  
  788.    This appendix is for informational purposes only and is not 
  789. required to meet the standard. 
  790.  
  791. p = Prime Modulus = 
  792. d0451ffe 2c64c4ed 6b0ae636 5b7fef9c 15425e40 a37ca5f8 39865e2c 
  793. fb4169a0 d825c913 0f8864ff fcf3bfbe b0273660 67aa27e2 7bfcaf40 
  794. 00000000 00000001 
  795.  
  796. q = Prime Divisor = 
  797. d9525756 704a663e 7323caf2 6fb8fc25 77e4fbeb 
  798.  
  799. g = Element of Order q Mod p = 
  800. acf958c4 0d301efc 5153e7dc d5ef75fe c9e8fb0f ae6a80ee 5c3b84b9 
  801. c0e51305 1b2b7542 e66b8d3a 25e93891 1ad6be5c 24395099 c6ddaa86 
  802. e18942f2 984275a 
  803.  
  804. x = Private Key = 
  805. 12345678 9abcdef0 12345678 9abcdef 
  806.  
  807. y = g^x mod p = Public Key = 
  808. 9d168087 c60c5cb3 aeb1e8ac c622f167 f1e97151 0b34876c 080d81b5 
  809. 20329817 e3e279fa 86eb6a9d 5e9e5897 5clf3d0d 3786ce04 abb0cab4 
  810. dfd9fa13 50bb3aa3 
  811.  
  812. k = Random Secret Integer = 
  813. bf27aa41 6c006dd4 b4f2806c 71171cc4 ce28db 
  814.  
  815. r = (g^k mod p) mod q = 
  816. 1c3d5143 a7beb085 9cbd08a2 039d7148 27ceddf9 
  817.  
  818. h = H(m) = Hash(message) = 
  819. 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a 
  820.  
  821. (h + xr) mod q = 
  822. 20215b52 aa605b7f 967991de b947a07f 13413a8a 8753d457 d1897afe 
  823. 786c8f82 5ecaal 
  824.  
  825. k^-1 mod q = 
  826. 5dfb26c8 208eda68 d8bb5fce 89732bae 595392e6 
  827.  
  828. s = (k^-1 (h + xr)) mod q = 
  829. 6f0be90c 72350564 77c69e89 ab6416b2 f365d95c 
  830.  
  831. w = s^-1 mod q = 
  832. 27fd6332 9e1cddf1 883b1d62 a345d9c5 f115d821 
  833.  
  834. u1 = (hw) mod q = 
  835. 6521b9e7 e0824239 0754396d c5327f98 c74fc641 
  836. u2 = (rw) mod q = 
  837. 52d754b2 153d3c14 483e65de 9895abe9 6bbb7751 
  838.  
  839. g^(u1) mod p = 
  840. c50370ba af79d463 7bf6ea24 579495de d0fd1190 2e5f8c5f 8524dd53 
  841. ee13c1e8 fb4ad43c db2e86f7 b892dc81 5e7676ab 11b48803 916e453b 
  842. f95bdfeb 93003009 
  843.  
  844. y^(u2) mod p = 
  845. 53b07663 b7078870 b640044f 592d1076 8b82fb49 1cfd10fe 4310a315 
  846. f3cf4de9 5ccff3df 926f837d 69afe707 640dd5a2 6fd41b11 1ff5cc6d 
  847. 51aa7453 d79ca533 
  848.  
  849. v = ((g^(u1) mod p)(y^(u2) mod p) mod p) mod q = 
  850. 1c3d5143 a7beb085 9cbd08a2 039d7148 27ceddf9 
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.